# 检验标签是否跟实际对应并统计各标签训练集个数
# 000014.txt 43
import os
import cv2
import glob
labels_path = "../data/labels/train/"
labels_base_path = "../data/labels/"
images_path = "../data/images/train/"
labels = os.listdir(labels_path)
labels_cn = [i.split("\n")[0] for i in open(labels_base_path+"labels.txt", encoding="utf-8").readlines()]
labels_en = [[i.split("\n")[0], 0] for i in open(labels_base_path+"classes.txt").readlines()]
for i in labels:
    file = labels_path+i
    f = open(file, encoding="utf-8")
    contents = ""
    while True:
        line = f.readline()
        if(line):
            items = line.split(" ")
            label = items[0]
            contents+=labels_cn[int(label)]+"、"
            label_num = labels_en[int(label)][1]
            labels_en[int(label)][1]+=1
        else:
            break
    print(i,contents)
    fname = i.split(".")[0]
    fl = glob.glob(images_path+fname+"*")
    cv2.imshow("test", cv2.imread(fl[0]))
    cv2.waitKey(0)
    cv2.destroyWindow("test")
print(labels_en)